@echo OFF
SETLOCAL EnableDelayedExpansion
echo -----------------------------------------
echo - Building SBC::COMA
echo -----------------------------------------

echo deleting target directory
rd /s/q deployment-units
mkdir deployment-units
echo created folder: deployment-units

echo performing install goal
call mvn clean install

echo .
echo .
echo creating commons assembly
cd /d Commons
call mvn package assembly:assembly
cd /d ..

echo .
echo .
echo creating producer assembly
cd /d Producer
call mvn package assembly:assembly
cd /d ..

echo .
echo .
echo creating assembly worker assembly
cd /d Assembly
call mvn package assembly:assembly
cd /d ..

echo .
echo .
echo creating tester worker assembly
cd /d Tester
call mvn package assembly:assembly
cd /d ..

echo .
echo .
echo creating logistics worker assembly
cd /d Logistics
call mvn package assembly:assembly
cd /d ..

echo .
echo .
echo creating load balancer assembly
cd /d Load-Balancer
call mvn package assembly:assembly
cd /d ..

echo .
echo .
echo compiling GUI
cd /d GUI
call mvn clean install
cd /d ..


echo copying files to target directory
copy Commons\target\coma-commons-distribution.zip deployment-units
copy Producer\target\producer-distribution.zip deployment-units
copy Assembly\target\assembly-worker-distribution.zip deployment-units
copy Tester\target\tester-worker-distribution.zip deployment-units
copy Logistics\target\logistics-worker-distribution.zip deployment-units
copy GUI\target\deployment\gui-distribution.zip deployment-units
copy Load-Balancer\target\load-balancer-distribution.zip deployment-units
copy rmi-benchmark.bat deployment-units
copy space-benchmark.bat deployment-units

echo .
echo .
echo DONE - Created deployment units